<?php
require_once("src/car/dao.class.php");	
require_once 'Pager/Pager.php';

$num_cars = CarDao::getTotalNumber();
$pager_options = array(
    'mode'       => 'Sliding',
    'perPage'    => 4,
    'delta'      => 2,
    'totalItems' => $num_cars,
);

$pager = Pager::factory($pager_options);
$cars = CarDao::findAllPaging($pager);

?> 
<table>
<?php 
echo $pager->links;
if (count($cars)>0) {
	foreach ($cars as $car) {
?>
	<tr valign="middle">
		<form name="browseCar" action="../<?php echo $www;?>/index_public.php" method="post">
			<input type="hidden" name="entity" value="car"/>
			<input type="hidden" name="action" value="details"/>
			<input type="hidden" name="title" value="Car Details"/>
			<input type="hidden" name="cid" value="<?php echo $car->id?>"/>
		<td>
			<div id="list-img">
				<input type="image" width="200px" height="150px" alt="<?php echo $car->photo?>" src="img/cars/<?php echo $car->photo?>" />
			</div>
		</td>
		<td colspan="4">
			<table>
				<tr>
					<td><b>Make:&nbsp;</b><?php echo $car->make?></td>
				</tr>
				<tr>
					<td><b>Model:&nbsp;</b><?php echo $car->model?></td>
				</tr>
				<tr>
					<td><b>Price:&nbsp;</b><?php echo $car->price?></td>
				</tr>
				<tr>
					<td><b>Color:&nbsp;</b><?php echo $car->color?></td>
				</tr>
				<tr>
					<td>
						<input type="submit" value="more details..." style="font-size: xx-small;"/>
					</td>
				</tr>
			</table>
		</td>
		</form>	
	</tr>
<?php 		
	}	
}
?>

</table>
<?php 
echo $pager->links;
?>

